package com.androturka.saycolor;

import android.content.Context;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.util.Log;

public class ColorVocalist {
    static final String TAG = "ColorVocalist";
	
	private static Context mContext;
	private static MediaPlayer mp;

	public ColorVocalist(Context mainClass)	{
		mContext = mainClass;
	}
    public int vocalizeColor( int ColorId ){
    	Log.i(TAG,"Vocalizing Color " + ColorId );

		switch (ColorId) {
			case Color.BLACK:
				if (mp != null) 
					mp.release();
				mp = MediaPlayer.create(mContext, R.raw.black);
		        if (mp != null)
		        	mp.start();
		        break;
			case Color.WHITE:
				if (mp != null) 
					mp.release();
				mp = MediaPlayer.create(mContext, R.raw.white);
		        if (mp != null)
		        	mp.start();
		        break;
			case Color.BLUE:
				if (mp != null) 
					mp.release();
				mp = MediaPlayer.create(mContext, R.raw.blue);
		        if (mp != null)
		        	mp.start();
		        break;
			case Color.GREEN:
				if (mp != null) 
					mp.release();
				mp = MediaPlayer.create(mContext, R.raw.green);
		        if (mp != null)
		        	mp.start();
		        break;
			case Color.RED:
				if (mp != null) 
					mp.release();
				mp = MediaPlayer.create(mContext, R.raw.red);
		        if (mp != null)
		        	mp.start();
		        break;
			case Color.YELLOW:
				if (mp != null) 
					mp.release();
				mp = MediaPlayer.create(mContext, R.raw.yellow);
		        if (mp != null)
		        	mp.start();
		        break;
			case Color.GRAY:
				if (mp != null) 
					mp.release();
				mp = MediaPlayer.create(mContext, R.raw.gray);
		        if (mp != null)
		        	mp.start();
		        break;
		    default:
				if (mp != null) 
					mp.release();
				mp = MediaPlayer.create(mContext, R.raw.unknown);
		        if (mp != null)
		        	mp.start();
		        break;
		}

    	
    	return 0;
    }
}
